package com.soft.javase.day08.removeduplicate;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yzh
 * @desc TODO
 * @date 2025/4/27
 */
public class StringRemoveDuplicate {
    public static void main(String[] args) {
        List<String> stringList = new ArrayList<>();
        stringList.add("aaa");
        stringList.add("bbb");
        stringList.add("aba");
        stringList.add("bbb");
        stringList.add("aaa");

        System.out.println("去重前的字符串列表: " + stringList);

        List<String> removedList = removeDuplicate(stringList);

        System.out.println("去重后的字符串列表: " + removedList);
    }

    public static List<String> removeDuplicate(List<String> list) {
        List<String> result = new ArrayList<>();
        for (String item : list) {
            if (!result.contains(item)) {
                result.add(item);
            }
        }
        return result;
    }
}
